#line 1 "..\\..\\app\\dataproc.c"
#line 1 "..\\..\\app\\dataProc.h"





 








#line 1 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"
 
 





 









     
#line 27 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"
     











#line 46 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"





 

     

     
typedef   signed          char int8_t;
typedef   signed short     int int16_t;
typedef   signed           int int32_t;
typedef   signed       __int64 int64_t;

     
typedef unsigned          char uint8_t;
typedef unsigned short     int uint16_t;
typedef unsigned           int uint32_t;
typedef unsigned       __int64 uint64_t;

     

     
     
typedef   signed          char int_least8_t;
typedef   signed short     int int_least16_t;
typedef   signed           int int_least32_t;
typedef   signed       __int64 int_least64_t;

     
typedef unsigned          char uint_least8_t;
typedef unsigned short     int uint_least16_t;
typedef unsigned           int uint_least32_t;
typedef unsigned       __int64 uint_least64_t;

     

     
typedef   signed           int int_fast8_t;
typedef   signed           int int_fast16_t;
typedef   signed           int int_fast32_t;
typedef   signed       __int64 int_fast64_t;

     
typedef unsigned           int uint_fast8_t;
typedef unsigned           int uint_fast16_t;
typedef unsigned           int uint_fast32_t;
typedef unsigned       __int64 uint_fast64_t;

     




typedef   signed           int intptr_t;
typedef unsigned           int uintptr_t;


     
typedef   signed     long long intmax_t;
typedef unsigned     long long uintmax_t;




     

     





     





     





     

     





     





     





     

     





     





     





     

     






     






     






     

     


     


     


     

     
#line 216 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"

     



     






     
    
 



#line 241 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"

     







     










     











#line 305 "C:\\Keil_v5\\ARM\\ARMCC\\Bin\\..\\include\\stdint.h"






 
#line 16 "..\\..\\app\\dataProc.h"
#line 1 "..\\..\\app\\rtctime.h"



#line 5 "..\\..\\app\\rtctime.h"






    
    typedef struct {
        uint8_t Sec; 		 
        uint8_t Min; 		 
        uint8_t Hour; 		 
		uint8_t Week;        
        uint8_t Day;		 
        uint8_t Mon; 	     
        uint16_t Year; 		 
    } TIME_Type;


    extern TIME_Type TimeCur;
    extern TIME_Type TimeStart;  
    extern TIME_Type TimeStop;   
    extern uint16_t CenturyCur;
    
    extern uint8_t RtcTimeSecLast;
    extern uint8_t bRtcPulse_1s;
    
    void TimeRun(void);
    void TimeSet(TIME_Type *pTime);
    void TimeGet(TIME_Type *pTime);
    int8_t TimeCompare(TIME_Type *pTime1,TIME_Type *pTime2);
    void TimeCopy(TIME_Type *pTimeSrc,TIME_Type *pTimeDes);
    void RtcTimePulseCreat(void);
    




#line 17 "..\\..\\app\\dataProc.h"
    
    


    
    typedef struct{
        uint8_t Inc;  
        uint8_t bDir; 
        uint16_t min; 
        uint16_t max; 
        uint16_t Out;
        uint32_t Cal;
    } led_breath_type;
    
    uint16_t AsciiToUpper(uint8_t *pSrc, uint16_t Len); 
    uint16_t AsciiToLower(uint8_t *pSrc, uint16_t Len); 
    
    void Hex4ToBCD4(uint16_t Data ,uint8_t *Des );
    void Hex4ToBCD8(uint16_t Data ,uint8_t *Des );
    void Hex2ToBCD2(uint8_t Data ,uint8_t *Des );
    void Hex2ToBCD4(uint8_t Data ,uint8_t *Des );
    
    uint8_t BCD2ToHex(uint8_t Data, uint8_t *Des);
    uint8_t BCD4ToHex(uint16_t Data, uint8_t *Des);
    uint8_t BCD8ToHex(uint32_t Data, uint8_t *Des);
    
    void Hex8ToAscii(uint32_t Num,uint8_t *Des);
    void Hex4ToAscii(uint16_t Num,uint8_t *Des);
    void Hex2ToAscii(uint8_t Num,uint8_t *Des);
    void Int16ToAscii(int16_t Num,uint8_t Attr,uint8_t *Des);
	void Uint16ToAscii(uint16_t Num,uint8_t Attr,uint8_t *Des);
    uint8_t Uint16ToString(uint16_t Num,uint8_t Attr,uint8_t *Des);
    uint8_t Int16ToString(int16_t Num,uint8_t Attr,uint8_t *Des);
    int16_t AsciiToInt16(uint8_t *pSrc, uint8_t Len);
    int16_t AsciiToInt16_P0(uint8_t *pSrc, uint8_t Len); 
    int16_t AsciiToInt16_P1(uint8_t *pSrc, uint8_t Len); 
    

    
    uint8_t EvenU8(uint8_t Data);                 
    uint8_t OddU8(uint8_t Data);                  
    uint8_t NoneParity(uint8_t Data);             
    
    int8_t ArrayComp(uint8_t *Array1, uint8_t *Array2, uint16_t Len); 
    uint8_t AsciiToHex2(uint8_t *Src);
    
    int8_t AsciiToTime(uint8_t *Src,TIME_Type *pTime);
    void TimeToAscii(TIME_Type *pTime,uint8_t *Des);
    void TimeNoSecToAscii(TIME_Type *pTime,uint8_t *Des);
    void DateToAscii(TIME_Type *pTime,uint8_t *Des);
    void ClockTimeToAscii(TIME_Type *pTime,uint8_t *Des);
    
    uint32_t LedBreathHandle(led_breath_type *Brj);
    






#line 2 "..\\..\\app\\dataproc.c"
#line 3 "..\\..\\app\\dataproc.c"
#line 1 "..\\..\\app\\pulse.h"




#line 6 "..\\..\\app\\pulse.h"





typedef struct {

    uint8_t bPulse_1s;
    uint8_t bPulse_500ms;
    uint8_t bPulse_250ms;
    uint8_t bPulse_100ms;
    
    uint8_t bPulse_50ms;
    uint8_t bPulse_30ms;
    uint8_t bPulse_20ms;
    uint8_t bPulse_10ms;
    
    uint16_t PulseTimeCnt_1s;
    uint16_t PulseTimeCnt_500ms;
    uint16_t PulseTimeCnt_250ms;
    uint16_t PulseTimeCnt_100ms;

    uint16_t PulseTimeCnt_50ms;
    uint16_t PulseTimeCnt_30ms;
    uint16_t PulseTimeCnt_20ms;
    uint16_t PulseTimeCnt_10ms;
    
    uint32_t AutoCnt; 

    uint32_t uTickLast;
} timer_pulse_type;


void    pulse_init(timer_pulse_type *pulse, uint32_t tickStart);
void    PulseCreat(timer_pulse_type *pulse, uint32_t uTick);





#line 4 "..\\..\\app\\dataproc.c"

 
typedef signed int          INT;
typedef signed char         INT8;
typedef signed short int    INT16;
typedef signed long int     INT32;

 
typedef unsigned int        UINT;
typedef unsigned char       UINT8;
typedef unsigned short int  UINT16;
typedef unsigned long int   UINT32;

typedef union
{
    UINT8 Val;
    struct
    {
        UINT8     b0 : 1;
        UINT8     b1 : 1;
        UINT8     b2 : 1;
        UINT8     b3 : 1;
        UINT8     b4 : 1;
        UINT8     b5 : 1;
        UINT8     b6 : 1;
        UINT8     b7 : 1;
    } bits;
} UINT8_VAL, UINT8_BITS;

typedef union
{
    UINT16 Val;
    UINT8  v[2];
    struct
    {
        UINT8 LB;
        UINT8 HB;
    } byte;
    struct
    {
        UINT16     b0 : 1;
        UINT16     b1 : 1;
        UINT16     b2 : 1;
        UINT16     b3 : 1;
        UINT16     b4 : 1;
        UINT16     b5 : 1;
        UINT16     b6 : 1;
        UINT16     b7 : 1;
        UINT16     b8 : 1;
        UINT16     b9 : 1;
        UINT16     b10 : 1;
        UINT16     b11 : 1;
        UINT16     b12 : 1;
        UINT16     b13 : 1;
        UINT16     b14 : 1;
        UINT16     b15 : 1;
    } bits;
} UINT16_VAL, UINT16_BITS;

typedef union
{
    UINT32 Val;
    UINT16 w[2]   ;
    UINT8  v[4]   ;
    struct
    {
        UINT16 LW;
        UINT16 HW;
    } word;
    struct
    {
        UINT8 LB;
        UINT8 HB;
        UINT8 UB;
        UINT8 MB;
    } byte;
    struct
    {
        UINT16_VAL low;
        UINT16_VAL high;
    } wordUnion;
    struct
    {
        UINT32     b0 : 1;
        UINT32     b1 : 1;
        UINT32     b2 : 1;
        UINT32     b3 : 1;
        UINT32     b4 : 1;
        UINT32     b5 : 1;
        UINT32     b6 : 1;
        UINT32     b7 : 1;
        UINT32     b8 : 1;
        UINT32     b9 : 1;
        UINT32     b10 : 1;
        UINT32     b11 : 1;
        UINT32     b12 : 1;
        UINT32     b13 : 1;
        UINT32     b14 : 1;
        UINT32     b15 : 1;
        UINT32     b16 : 1;
        UINT32     b17 : 1;
        UINT32     b18 : 1;
        UINT32     b19 : 1;
        UINT32     b20 : 1;
        UINT32     b21 : 1;
        UINT32     b22 : 1;
        UINT32     b23 : 1;
        UINT32     b24 : 1;
        UINT32     b25 : 1;
        UINT32     b26 : 1;
        UINT32     b27 : 1;
        UINT32     b28 : 1;
        UINT32     b29 : 1;
        UINT32     b30 : 1;
        UINT32     b31 : 1;
    } bits;
} UINT32_VAL;

typedef unsigned char           BYTE;                            
typedef unsigned short int      WORD;                            
typedef unsigned long           DWORD;                           

typedef union
{
    BYTE Val;
    struct
    {
        UINT8     b0 : 1;
        UINT8     b1 : 1;
        UINT8     b2 : 1;
        UINT8     b3 : 1;
        UINT8     b4 : 1;
        UINT8     b5 : 1;
        UINT8     b6 : 1;
        UINT8     b7 : 1;
    } bits;
} BYTE_VAL, BYTE_BITS;

typedef union
{
    WORD Val;
    BYTE v[2]   ;
    struct
    {
        BYTE LB;
        BYTE HB;
    } byte;
    struct
    {
        UINT16     b0 : 1;
        UINT16     b1 : 1;
        UINT16     b2 : 1;
        UINT16     b3 : 1;
        UINT16     b4 : 1;
        UINT16     b5 : 1;
        UINT16     b6 : 1;
        UINT16     b7 : 1;
        UINT16     b8 : 1;
        UINT16     b9 : 1;
        UINT16     b10 : 1;
        UINT16     b11 : 1;
        UINT16     b12 : 1;
        UINT16     b13 : 1;
        UINT16     b14 : 1;
        UINT16     b15 : 1;
    } bits;
} WORD_VAL, WORD_BITS;

typedef union
{
    DWORD Val;
    WORD w[2]   ;
    BYTE v[4]   ;
    struct
    {
        WORD LW;
        WORD HW;
    } word;
    struct
    {
        BYTE LB;
        BYTE HB;
        BYTE UB;
        BYTE MB;
    } byte;
    struct
    {
        UINT32     b0 : 1;
        UINT32     b1 : 1;
        UINT32     b2 : 1;
        UINT32     b3 : 1;
        UINT32     b4 : 1;
        UINT32     b5 : 1;
        UINT32     b6 : 1;
        UINT32     b7 : 1;
        UINT32     b8 : 1;
        UINT32     b9 : 1;
        UINT32     b10 : 1;
        UINT32     b11 : 1;
        UINT32     b12 : 1;
        UINT32     b13 : 1;
        UINT32     b14 : 1;
        UINT32     b15 : 1;
        UINT32     b16 : 1;
        UINT32     b17 : 1;
        UINT32     b18 : 1;
        UINT32     b19 : 1;
        UINT32     b20 : 1;
        UINT32     b21 : 1;
        UINT32     b22 : 1;
        UINT32     b23 : 1;
        UINT32     b24 : 1;
        UINT32     b25 : 1;
        UINT32     b26 : 1;
        UINT32     b27 : 1;
        UINT32     b28 : 1;
        UINT32     b29 : 1;
        UINT32     b30 : 1;
        UINT32     b31 : 1;
    } bits;
} DWORD_VAL, DWORD_BITS;



 
uint16_t AsciiToUpper(uint8_t *pSrc, uint16_t Len) 
{
    uint16_t Cnt;

    Cnt = 0;
    while(Len--)
    {
        if( ('a' <= *pSrc) && ('z' >= *pSrc))
        {
            (*pSrc++) -= 'a' - 'A';
            Cnt++;
        }
    }

    return Cnt;
}



 
uint16_t AsciiToLower(uint8_t *pSrc, uint16_t Len) 
{
    uint16_t Cnt;

    Cnt = 0;
    while(Len--)
    {
        if( ('A' <= *pSrc) && ('Z' >= *pSrc))
        {
            (*pSrc++) += 'a' - 'A';
            Cnt++;
        }
    }

    return Cnt;
}




 
void Hex4ToBCD4(uint16_t Data ,uint8_t *Des )                   
{
    if(Data > 9999)
        Data = Data % 10000;

    *(Des+1) = Data / 1000;
    Data %= 1000;
    *(Des+1) <<= 4;
    *(Des+1) |= Data / 100;
    Data %= 100;

    *(Des) = Data / 10;
    *(Des) <<= 4;
    *(Des) |= Data % 10;
}


 
void Hex4ToBCD8(uint16_t Data ,uint8_t *Des )                   
{
    *(Des+3) = 0;

    Data -= (*(Des+2) = Data / 10000) * 10000;
    Data -= (*(Des+1) = Data / 1000) * 1000;
    *(Des+1) <<= 4;
    Data -= (*(Des+1) += Data / 100) * 100;
    Data -= (*(Des) = Data / 10) * 10;
    *Des <<= 4;
    *(Des) += (uint8_t)Data;
}


 
void Hex2ToBCD2(uint8_t Data ,uint8_t *Des )                   
{
    if(Data > 99)
        Data = Data % 100;

    *Des = Data / 10;
    Data -= *Des * 10;
    *Des <<= 4;
    *(Des) += (uint8_t)Data;
}


 
void Hex2ToBCD4(uint8_t Data ,uint8_t *Des )                   
{

    Data -= (*(Des+1) = Data / 100)*100;

    Data -= (*(Des) = Data / 10) * 10;
    *Des <<= 4;
    *(Des) += (uint8_t)Data;
}


 
uint8_t BCD2ToHex(uint8_t Data, uint8_t *Des)
{
    uint8_t Cnt;
    uint8_t Division;
    uint16_t Mid;
    Cnt = 2;
    Mid = 0;
    while(Cnt --)
    {
        Mid *= 10;
        Division = (Data >> (4*Cnt)) & 0x0F;
        if(Division > 9)
            return 0x21;
        Mid += Division;
    }

    *(Des) = Mid;
    return 0x0;
}


 
uint8_t BCD4ToHex(uint16_t Data, uint8_t *Des)
{
    uint8_t Cnt;
    uint8_t Division;
    uint16_t Mid;
    Cnt = 4;
    Mid = 0;
    while(Cnt --)
    {
        Mid *= 10;
        Division = (Data >> (4*Cnt)) & 0x0F;
        if(Division > 9)
            return 0x21;
        Mid += Division;
    }

    *((uint16_t*)Des) = Mid;
    return 0x0;
}



 
uint8_t BCD8ToHex(uint32_t Data, uint8_t *Des)
{
    uint8_t Cnt;
    uint8_t Division;
    uint32_t Mid;
    Cnt = 8;
    Mid = 0;
    while(Cnt --)
    {
        Mid *= 10;
        Division = (Data >> (4*Cnt)) & 0x0F;
        if(Division > 9)
            return 0x21;
        Mid += Division;
    }

    *((uint32_t*)Des) = Mid;
    return 0x0;
}



 
void Hex8ToAscii(uint32_t Num,uint8_t *Des)
{
    uint8_t DesNum;
    DWORD_VAL NumTemp;

    NumTemp.Val = Num;
    *(Des++) = NumTemp.byte.MB >> 4   ;
    *(Des++) = NumTemp.byte.MB & 0x0F ;
    *(Des++) = NumTemp.byte.UB >> 4   ;
    *(Des++) = NumTemp.byte.UB & 0x0F ;
    *(Des++) = NumTemp.byte.HB >> 4   ;
    *(Des++) = NumTemp.byte.HB & 0x0F ;
    *(Des++) = NumTemp.byte.LB >> 4   ;
    *(Des++) = NumTemp.byte.LB & 0x0F ;

    Des -= 8;
    DesNum = 8;

    while(DesNum--)
    {
        if(*Des < 10)
            *Des  +=  0x30;
        else
            *Des  +=  ('A' - 10);
        Des ++;
    }
}


 
void Hex4ToAscii(uint16_t Num,uint8_t *Des)
{
    uint8_t DesNum;
    WORD_VAL NumTemp;

    NumTemp.Val = Num;
    *(Des++) = NumTemp.byte.HB >> 4   ;
    *(Des++) = NumTemp.byte.HB & 0x0F ;
    *(Des++) = NumTemp.byte.LB >> 4   ;
    *(Des++) = NumTemp.byte.LB & 0x0F ;

    Des -= 4;
    DesNum = 4;

    while(DesNum--)
    {
        if(*Des < 10)
            *Des  +=  0x30;
        else
            *Des  +=  ('A' - 10);
        Des ++;
    }
}


 
void Hex2ToAscii(uint8_t Num,uint8_t *Des)
{
    uint8_t DesNum;

    *(Des++) = Num >> 4   ;
    *(Des++) = Num  & 0x0F ;

    Des   -= 2;
    DesNum = 2;

    while(DesNum--)
    {
        if(*Des < 10)
            *Des  +=  0x30;
        else
            *Des  +=  ('A' - 10);
        Des ++;
    }
}



 
uint8_t AsciiToHex2(uint8_t *Src)
{
    uint8_t Num;

    if((*Src >= '0') && (*Src <= '9'))
    {
        Num = (*Src-'0') << 4;
    }
    else if((*Src >= 'A') && (*Src <= 'F'))
    {
        Num = (*Src-('A' - 10)) << 4;
    }
    else
    {
        Num = 0;
    }

    Src ++;


    if((*Src >= '0') && (*Src <= '9'))
    {
        Num |= (*Src-'0');
    }
    else if((*Src >= 'A') && (*Src <= 'F'))
    {
        Num |= (*Src-('A' - 10));
    }
    else
    {
        Num |= 0;
    }

    return Num;
}


 










 
int16_t AsciiToInt16(uint8_t *pSrc, uint8_t Len)
{
    uint8_t Index;
    uint8_t Symbol;   
    uint8_t Cnt;

    uint32_t Data;


    if(Len > 5)
        return 0;
    else if(0 == Len)
        Len = 5;

    Cnt = 0;
    Symbol = 0;
    Data = 0;

    for(Index = 0; Cnt < Len; Index++)
    {
        if(' ' == pSrc[Index])
        {
            continue;
        }
        else
        {
            if(Symbol & 0x10) 
            {
                if('.' == pSrc[Index])
                {
                    if(Symbol & 0x40)
                    {
                        
                        break;
                    }
                    Symbol |= 0x40;
                }
                else if((pSrc[Index] >= '0') && (pSrc[Index] <= '9'))
                {
                    Cnt++;
                    Data *= 10;
                    Data += pSrc[Index] - '0';
                }
                else
                {
                    
                    break;
                }
            }
            else
            {
                
                if('-' == pSrc[Index])
                {
                    
                    Symbol |= 0x01;   
                    Data = 0;
                }
                else
                {
                    
                    if('.' == pSrc[Index])
                    {
                        Symbol |= 0x40; 
                        Data = 0;
                    }
                    else if((pSrc[Index] >= '0') && (pSrc[Index] <= '9'))
                    {
                        Data = pSrc[Index] - '0';
                        Cnt++;
                    }
                    else
                    {
                        
                        Data = 0;
                        break;
                    }
                }
            }

            Symbol |= 0x10; 

        }
    }

    
    if(Data > 0x7FFF)
        Data /= 10;

    if(Symbol &= 0x01)
    {
        Data = -Data;
    }

    return *((int16_t*)(&Data));
}

 










 
int16_t AsciiToInt16_P0(uint8_t *pSrc, uint8_t Len)
{
    uint8_t Index;
    uint8_t Symbol;   
    uint8_t Cnt;

    uint32_t Data;


    if(Len > 5)
        Len = 5;
    else if(0 == Len)
        Len = 5;

    Cnt = 0;
    Symbol = 0;
    Data = 0;

    for(Index = 0; Cnt < Len; Index++)
    {
        if(' ' == pSrc[Index])
        {
            continue;
        }
        else if((pSrc[Index] >= '0')&&(pSrc[Index] <= '9'))
        {

            Cnt++;
            Data *= 10;
            Data += pSrc[Index] - '0';
            Symbol |= 0x10; 
        }
        else if('-' == pSrc[Index])
        {
            if(Symbol & 0x10)
            {
                
                break;
            }
            else
            {
                
                Symbol |= 0x01;   
                Data = 0;
                Symbol |= 0x10;   
            }
        }
        else
        {
            break;
        }
    }

    
    if(Data > 0x7FFF)
        Data /= 10;

    if(Symbol &= 0x01)
    {
        Data = -Data;
    }

    return *((int16_t*)(&Data));
}

 










 
int16_t AsciiToInt16_P1(uint8_t *pSrc, uint8_t Len)
{
    uint8_t Index;
    uint8_t Symbol;   
    uint8_t Cnt;
    uint8_t PointCnt; 
    uint32_t Data;


    if(Len > 5)
        Len = 5;
    else if(0 == Len)
        Len = 5;

    PointCnt = 0;
    Cnt = 0;
    Symbol = 0;
    Data = 0;

    for(Index = 0; Cnt < Len; Index++)
    {
        if(' ' == pSrc[Index])
        {
            continue;
        }
        else if((pSrc[Index] >= '0')&&(pSrc[Index] <= '9'))
        {

            Cnt++;
            Data *= 10;
            Data += pSrc[Index] - '0';
            Symbol |= 0x10; 

            if(Symbol & 0x20)
            {
                PointCnt++;
                break;
            }
        }
        else if('.' == pSrc[Index])
        {
            if(Symbol & 0x20)
            {
                
                break;
            }
            else
            {
                Symbol |= 0x10;   
                Symbol |= 0x20;   
            }
        }
        else if('-' == pSrc[Index])
        {
            if(Symbol & 0x10)
            {
                
                break;
            }
            else
            {
                
                Symbol |= 0x01;   
                Symbol |= 0x10;   
            }
        }
        else
        {
            break;
        }
    }


    if(0 == PointCnt)
    {
        
        while(Data > (0x7FFF/10))
            Data /= 10;
        Data *= 10;
    }
    else
    {
        
        if(Data > 0x7FFF)
        {
            
            while(Data > (0x7FFF/10))
                Data /= 10;
            Data *= 10;
        }
    }

    if(Symbol &= 0x01)
    {
        Data = -Data;
    }

    return *((int16_t*)(&Data));
}


 














 
void Uint16ToAscii(uint16_t Num,uint8_t Attr,uint8_t *Des)
{
    uint16_t Data;
    uint8_t  Index;

    Data = Num;
    Index = 0;
    
    switch((Attr & 0x07)+1)
    {
    case 5 :
        Des[Index] = Data / 10000;
        Data -= Des[Index] * 10000;
        Des[Index] += '0';
        Index ++;
    case 4 :
        Des[Index] = Data / 1000;
        Data -= Des[Index] * 1000;
        Des[Index] += '0';
        Index ++;
    case 3 :
        Des[Index] = Data / 100;
        Data -= Des[Index] * 100;
        Des[Index] += '0';
        Index ++;
    case 2 :
        Des[Index] = Data / 10;
        Data -= Des[Index] * 10;
        Des[Index] += '0';
        Index ++;
    case 1 :
        Des[Index] = Data ;
        Des[Index] += '0';
        break;
    default :
        return;
    }
    
    switch(Attr & 0x30)
    {
    case 0x00:
        break;
    case 0x10:
        Des[Index+1] = Des[Index];
        Des[Index] = '.';
        Index++;
        break;
    case 0x20:
        Des[Index+1] = Des[Index];
        Des[Index] = Des[Index-1];
        Des[Index-1] = '.';
        Index++;
        break;
    default :
        break;

    }

    Index++;
    Des[Index] = 0;

    
    if(Attr & 0x80)
    {
        if((Des[0] == '0') && (Des[1]!= '.') && (Des[1]!= 0))
        {
            Des[0] = ' ';
            if((Des[1] == '0') && (Des[2]!= '.') && (Des[2]!= 0))
            {
                Des[1] = ' ';
                if((Des[2] == '0') && (Des[3]!= '.') && (Des[3]!= 0))
                {
                    Des[2] = ' ';
                    if((Des[3] == '0') && (Des[4]!= '.') && (Des[4]!= 0))
                    {
                        Des[3] = ' ';
                    }
                }
            }
        }
    }
}

 













 
uint8_t Uint16ToString(uint16_t Num,uint8_t Attr,uint8_t *Des)
{
    uint16_t Data;
    uint8_t  Index;
    uint8_t  Cnt;

    Data = Num;
    Index = 0;
    

    Des[Index] = Data / 10000;
    Data -= Des[Index] * 10000;
    Des[Index] += '0';
    Index ++;
    Des[Index] = Data / 1000;
    Data -= Des[Index] * 1000;
    Des[Index] += '0';
    Index ++;
    Des[Index] = Data / 100;
    Data -= Des[Index] * 100;
    Des[Index] += '0';
    Index ++;
    Des[Index] = Data / 10;
    Data -= Des[Index] * 10;
    Des[Index] += '0';
    Index ++;
    Des[Index] = Data ;
    Des[Index] += '0';

    
    switch(Attr & 0x30)
    {
    case 0x00:
        break;
    case 0x10:
        Des[Index+1] = Des[Index];
        Des[Index] = '.';
        Index++;
        break;
    case 0x20:
        Des[Index+1] = Des[Index];
        Des[Index] = Des[Index-1];
        Des[Index-1] = '.';
        Index++;
        break;
    default :
        break;

    }

    Index++;
    Des[Index] = 0;

    
    Cnt = 0;
    while(('0' == Des[Cnt]) && (0 != Des[Cnt+1]) && ('.' != Des[Cnt+1]))
        Cnt++;
    
    Index = 0;
    while(0 != Des[Cnt])
    {
        Des[Index++] = Des[Cnt];
        Cnt++;
    }
    return Index;
}

 















 
void Int16ToAscii(int16_t Num,uint8_t Attr,uint8_t *Des)
{
    uint16_t Data;
    uint8_t  Index;

    Index = 1;

    if(Num < 0)
    {
        Data = 0-Num;
        *Des = '-';
    }
    else
    {
        Data = Num;
        *Des = ' ';
    }

    
    switch((Attr & 0x07)+1)
    {
    case 5 :
        Des[Index] = Data / 10000;
        Data -= Des[Index] * 10000;
        Des[Index] += '0';
        Index ++;
    case 4 :
        Des[Index] = Data / 1000;
        Data -= Des[Index] * 1000;
        Des[Index] += '0';
        Index ++;
    case 3 :
        Des[Index] = Data / 100;
        Data -= Des[Index] * 100;
        Des[Index] += '0';
        Index ++;
    case 2 :
        Des[Index] = Data / 10;
        Data -= Des[Index] * 10;
        Des[Index] += '0';
        Index ++;
    case 1 :
        Des[Index] = Data ;
        Des[Index] += '0';
        break;
    default :
        return;
    }
    
    switch(Attr & 0x30)
    {
    case 0x00:
        break;
    case 0x10:
        Des[Index+1] = Des[Index];
        Des[Index] = '.';
        Index++;
        break;
    case 0x20:
        Des[Index+1] = Des[Index];
        Des[Index] = Des[Index-1];
        Des[Index-1] = '.';
        Index++;
        break;
    default :
        break;

    }

    Index++;
    Des[Index] = 0;

    
    if(Attr & 0x80)
    {
        if((Des[1] == '0') && (Des[2]!= '.') && (Des[2]!= 0))
        {
            Des[1] = *Des;
            *Des = ' ';
            if((Des[2] == '0') && (Des[3]!= '.') && (Des[3]!= 0))
            {
                Des[2] = Des[1];
                Des[1] = ' ';
                if((Des[3] == '0') && (Des[4]!= '.') && (Des[4]!= 0))
                {
                    Des[3] = Des[2];
                    Des[2] = ' ';
                    if((Des[4] == '0') && (Des[5]!= '.') && (Des[5]!= 0))
                    {
                        Des[4] = Des[3];
                        Des[3] = ' ';
                    }
                }
            }
        }
    }
}


 












 
uint8_t Int16ToString(int16_t Num,uint8_t Attr,uint8_t *Des)
{
    uint16_t Data;
    uint8_t  Index;
    uint8_t Cnt;

    Index = 1;

    if(Num < 0)
    {
        Data = 0-Num;
        *Des = '-';
    }
    else
    {
        Data = Num;
        *Des = ' ';
    }

    

    Des[Index] = Data / 10000;
    Data -= Des[Index] * 10000;
    Des[Index] += '0';
    Index ++;
    Des[Index] = Data / 1000;
    Data -= Des[Index] * 1000;
    Des[Index] += '0';
    Index ++;
    Des[Index] = Data / 100;
    Data -= Des[Index] * 100;
    Des[Index] += '0';
    Index ++;
    Des[Index] = Data / 10;
    Data -= Des[Index] * 10;
    Des[Index] += '0';
    Index ++;
    Des[Index] = Data ;
    Des[Index] += '0';

    
    switch(Attr & 0x30)
    {
    case 0x00:
        break;
    case 0x10:
        Des[Index+1] = Des[Index];
        Des[Index] = '.';
        Index++;
        break;
    case 0x20:
        Des[Index+1] = Des[Index];
        Des[Index] = Des[Index-1];
        Des[Index-1] = '.';
        Index++;
        break;
    default :
        break;

    }

    Index++;
    Des[Index] = 0;

    
    {
        if((Des[1] == '0') && (Des[2]!= '.') && (Des[2]!= 0))
        {
            Des[1] = *Des;
            *Des = ' ';
            if((Des[2] == '0') && (Des[3]!= '.') && (Des[3]!= 0))
            {
                Des[2] = Des[1];
                Des[1] = ' ';
                if((Des[3] == '0') && (Des[4]!= '.') && (Des[4]!= 0))
                {
                    Des[3] = Des[2];
                    Des[2] = ' ';
                    if((Des[4] == '0') && (Des[5]!= '.') && (Des[5]!= 0))
                    {
                        Des[4] = Des[3];
                        Des[3] = ' ';
                    }
                }
            }
        }
    }

    
    Cnt = 0;
    while((' ' == Des[Cnt]) && (0 != Des[Cnt+1]) && ('.' != Des[Cnt+1]))
        Cnt++;
    
    Index = 0;
    while(0 != Des[Cnt])
    {
        Des[Index++] = Des[Cnt];
        Cnt++;
    }

    return Index;
}



 
uint8_t EvenU8(uint8_t Data)           
{
    Data ^= Data >> 4;                  
    Data ^= Data >> 2;                  
    Data ^= Data >> 1;                  
    
    return (Data & 0x01);
}


 
uint8_t OddU8(uint8_t Data)                  
{
    Data ^= Data >> 4;                  
    Data ^= Data >> 2;                  
    Data ^= Data >> 1;                  
    Data ++ ;                           
    
    return (Data & 0x01);
}


 
uint8_t NoneParity(uint8_t Data)
{
    Data = 1;
    return Data;
}


 









 
int8_t ArrayComp(uint8_t *Array1, uint8_t *Array2, uint16_t Len)
{
    uint16_t Index;
    int8_t  Resualt;
    Index = 0;
    Resualt = 0;
    for(; Index < Len; Index ++)
    {
        if(Array1[Index] > Array2[Index])
        {
            Resualt = 1;
            break;
        }
        else if(Array1[Index] > Array2[Index])
        {
            Resualt = -1;
            break;
        }
    }
    return Resualt;
}

 














 
int8_t AsciiToTime(uint8_t *Src,TIME_Type *pTime)
{
    uint8_t  Index;
    uint16_t Val;
    uint8_t  St;
    
    
    
    

    pTime->Year = 0;
    pTime->Mon = 0;
    pTime->Day = 0;
    pTime->Hour = 0;
    pTime->Min = 0;
    pTime->Sec = 0;

    Index = 0;
    St = 0;

    
    while((Src[Index] >= '0') && (Src[Index] <= '9'))
    {
        Index++;
        if(Index > 5)
            return 0;
    }

    
    if('-' == Src[Index])
    {
        St = 0;
    }
    else if(':' == Src[Index])
    {
        St = 3;
    }
    else
    {
        return 0;
    }

    Index = 0;
    Val = 0;
    
    while(1)
    {
        if((Src[Index] >= '0') && (Src[Index] <= '9'))
        {
            Val *= 10;
            Val += Src[Index] - '0';
        }
        else if(('-' == Src[Index])||(':' == Src[Index])||(' ' == Src[Index]))
        {
            St |= 0x80;
        }
        else
        {
            St |= 0xC0;
        }

        if(St & 0x80) 
        {
            switch(St & 0x07)
            {
            case 0:
                pTime->Year = Val;
                Val = 0;
                St++;
                break;
            case 1:
                if((Val >= 1)&&(Val<=12))
                {
                    pTime->Mon  = Val;
                }
                else
                {
                    St|=0x20;
                }
                Val = 0;
                St++;
                break;
            case 2:
                if((Val >= 1)&&(Val<=31))
                {
                    pTime->Day  = Val;
                }
                else
                {
                    St|=0x20;
                }
                Val = 0;
                St++;
                break;
            case 3:
                if(            (Val<=23))
                {
                    pTime->Hour = Val;
                }
                else
                {
                    St|=0x20;
                }
                Val = 0;
                St++;
                break;
            case 4:
                if(            (Val<=59))
                {
                    pTime->Min  = Val;
                }
                else
                {
                    St|=0x20;
                }
                Val = 0;
                St++;
                break;
            case 5:
                if(            (Val<=59))
                {
                    pTime->Sec  = Val;
                }
                else
                {
                    St|=0x20;
                }
                Val = 0;
                St++;
                break;
            default :
                return 0;
            }
            
            St &= 0x7F;
        }

        
        if(St & 0x20)
        {
            pTime->Year = 0;
            pTime->Mon = 0;
            pTime->Day = 0;
            pTime->Hour = 0;
            pTime->Min = 0;
            pTime->Sec = 0;
            return 0;
        }

        
        if(St & 0x40)
        {
            return 1;
        }
        Index++;
    }
}

 







 
void TimeToAscii(TIME_Type *pTime,uint8_t *Des)
{
    Uint16ToAscii(pTime->Year,0x03,Des);
    Des+=4;
    *Des++='-';
    Uint16ToAscii(pTime->Mon,0x01,Des);
    Des+=2;
    *Des++='-';
    Uint16ToAscii(pTime->Day,0x01,Des);
    Des+=2;
    *Des++=' ';
    Uint16ToAscii(pTime->Hour,0x01,Des);
    Des+=2;
    *Des++=':';
    Uint16ToAscii(pTime->Min,0x01,Des);
    Des+=2;
    *Des++=':';
    Uint16ToAscii(pTime->Sec,0x01,Des);
    Des+=2;
}

 







 
void TimeNoSecToAscii(TIME_Type *pTime,uint8_t *Des)
{
    Uint16ToAscii(pTime->Year,0x03,Des);
    Des+=4;
    *Des++='-';
    Uint16ToAscii(pTime->Mon,0x01,Des);
    Des+=2;
    *Des++='-';
    Uint16ToAscii(pTime->Day,0x01,Des);
    Des+=2;
    *Des++=' ';
    Uint16ToAscii(pTime->Hour,0x01,Des);
    Des+=2;
    *Des++=':';
    Uint16ToAscii(pTime->Min,0x01,Des);
    Des+=2;
}

 







 
void DateToAscii(TIME_Type *pTime,uint8_t *Des)
{
    Uint16ToAscii(pTime->Year,0x03,Des);
    Des+=4;
    *Des++='-';
    Uint16ToAscii(pTime->Mon,0x01,Des);
    Des+=2;
    *Des++='-';
    Uint16ToAscii(pTime->Day,0x01,Des);
}

 







 
void ClockTimeToAscii(TIME_Type *pTime,uint8_t *Des)
{
    Uint16ToAscii(pTime->Hour,0x01,Des);
    Des+=2;
    *Des++=':';
    Uint16ToAscii(pTime->Min,0x01,Des);
    Des+=2;
    *Des++=':';
    Uint16ToAscii(pTime->Sec,0x01,Des);
}

 








 
uint32_t LedBreathHandle(led_breath_type *Brj)
{
    uint32_t Min,Max,Cal;

    Cal = Brj->Cal;
    Min = Brj->min<<8;
    Max = Brj->max<<8;

    if(Brj->bDir)
    {
        if(Cal < Min)
            Cal = Min;

        Cal += Cal >> Brj->Inc ;

        if(Cal >= Max)
        {
            Cal = Max;
            Brj->bDir = 0;
        }
    }
    else
    {
        Cal -= Cal>>Brj->Inc;

        if(Cal <= Min)
        {
            Cal = Min;
            Brj->bDir = 1;
        }
    }
    Brj->Cal = Cal;
    Brj->Out = Cal>>8;
    return (Brj->Out);
}

void    pulse_init(timer_pulse_type *pulse, uint32_t tickStart)
{
    pulse->bPulse_1s = 0;
    pulse->bPulse_500ms = 0;
    pulse->bPulse_250ms = 0;
    pulse->bPulse_100ms = 0;
    pulse->bPulse_50ms = 0;
    pulse->bPulse_30ms = 0;
    pulse->bPulse_20ms = 0;
    pulse->bPulse_10ms = 0;
    
    pulse->PulseTimeCnt_1s = 0;
    pulse->PulseTimeCnt_500ms = 0;
    pulse->PulseTimeCnt_250ms = 0;
    pulse->PulseTimeCnt_100ms = 0;
    pulse->PulseTimeCnt_50ms = 0;
    pulse->PulseTimeCnt_30ms = 0;
    pulse->PulseTimeCnt_20ms = 0;
    pulse->PulseTimeCnt_10ms = 0;
    
    
    pulse->AutoCnt = 0;
    pulse->uTickLast = tickStart;
}

void    PulseCreat(timer_pulse_type *pulse, uint32_t uTick)
{

    uint16_t TickInc;

    TickInc = uTick - pulse->uTickLast;
    pulse->uTickLast = uTick;

    pulse->bPulse_1s = 0;
    pulse->bPulse_500ms = 0;
    pulse->bPulse_250ms = 0;
    pulse->bPulse_100ms = 0;
    pulse->bPulse_50ms = 0;
    pulse->bPulse_30ms = 0;
    pulse->bPulse_20ms = 0;
    pulse->bPulse_10ms = 0;

    if (0 == TickInc)
        return;

    pulse->PulseTimeCnt_1s += TickInc;
    pulse->PulseTimeCnt_500ms += TickInc;
    pulse->PulseTimeCnt_250ms += TickInc;
    pulse->PulseTimeCnt_100ms += TickInc;
    pulse->PulseTimeCnt_50ms += TickInc;
    pulse->PulseTimeCnt_30ms += TickInc;
    pulse->PulseTimeCnt_20ms += TickInc;
    pulse->PulseTimeCnt_10ms += TickInc;

    if (pulse->PulseTimeCnt_1s >= (1000 / 1))
    {
        pulse->PulseTimeCnt_1s -= (1000 / 1);
        pulse->bPulse_1s = 1;
    }

    if (pulse->PulseTimeCnt_500ms >= (500 / 1))
    {
        pulse->PulseTimeCnt_500ms -= (500 / 1);
        pulse->bPulse_500ms = 1;
    }

    if (pulse->PulseTimeCnt_250ms >= (250 / 1))
    {
        pulse->PulseTimeCnt_250ms -= (250 / 1);
        pulse->bPulse_250ms = 1;
    }

    if (pulse->PulseTimeCnt_100ms >= (100 / 1))
    {
        pulse->PulseTimeCnt_100ms -= (100 / 1);
        pulse->bPulse_100ms = 1;


    }

    if (pulse->PulseTimeCnt_50ms >= (50 / 1))
    {
        pulse->PulseTimeCnt_50ms -= (50 / 1);
        pulse->bPulse_50ms = 1;
    }

    if (pulse->PulseTimeCnt_30ms >= (30 / 1))
    {
        pulse->PulseTimeCnt_30ms -= (30 / 1);
        pulse->bPulse_30ms = 1;
    }

    if (pulse->PulseTimeCnt_20ms >= (20 / 1))
    {
        pulse->PulseTimeCnt_20ms -= (20 / 1);
        pulse->bPulse_20ms = 1;
    }

    if (pulse->PulseTimeCnt_50ms >= (10 / 1))
    {
        pulse->PulseTimeCnt_50ms -= (10 / 1);
        pulse->bPulse_10ms = 1;

        pulse->AutoCnt++;
    }
}


